package my.tool;

import java.io.File;

import my.myspring.tool.SpringBeanProxy;

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 2010-6-10
 * Time: 17:40:14
 * To change this template use File | Settings | File Templates.
 */
public class ConfigUtil {
    public static String getClassPath(){
       String classpath=ConfigUtil.class.getResource("").getPath();
       int index=classpath.indexOf("/WEB-INF/");
       if(index>-1){
           classpath=classpath.substring(0,index)+"/WEB-INF/classes/";
           if(classpath.startsWith("file:")){
               classpath=classpath.substring("file:".length());
           }
           return classpath;
       }
       return ConfigUtil.class.getResource("/").getPath();
    }

    public static String getConstantPath(){
        String path=getClassPath();
        if(path.endsWith("classes/")) path=path.substring(0,path.length()-"classes/".length());
        return path;
    }

    public static void main(String[] args){
        System.out.println(SpringBeanProxy.getBean("DefaultDataSource"));
    }
}
